package hp.com.servlet.CartDataServlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@WebServlet("/Payment_Success")
public class BuyCar_ThreeShowServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //判断是否登录且获取对象
        HttpSession session = req.getSession();
        if(session.getAttribute("userSession")==null){
            req.getRequestDispatcher(req.getContextPath()+"/Login").forward(req,resp);
        }else{
        try{
            req.setCharacterEncoding("utf-8");
            req.getRequestDispatcher(req.getContextPath()+"ShopPage/paymentSuccess.jsp").forward(req,resp);
        } catch (Exception exception) {
            exception.printStackTrace();
        }}
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
